#pragma once
#include "RenderTarget.h"
#include "Runtime/CGI/CGICommandList.h"
#include "Runtime/Utils/SmartPtr.h";

namespace Alice{
    enum EWindowMode:int;
    class World;
    class GameInstance;
    class ViewportWidget;
    class ViewportClient;
    class Viewport : public RenderTarget
    {
    public:
        ViewportClient* mViewportClient;
        SmartPtr<CGIViewport> mCGIViewport;
        Viewport(ViewportClient*inViewportClient);
        virtual void EnqueueBeginRenderFrame(const bool bShouldPresent);
        virtual void EnqueueEndRenderFrame(const bool bShouldPresent,const bool bLockToVsync);
        virtual void BeginRenderFrame(CGICommandListImmediate& RHICmdList);
        virtual void EndRenderFrame(CGICommandListImmediate& RHICmdList, bool bPresent, bool bLockToVsync);
        virtual void UpdateViewportRHI(bool bDestroyed, uint32 NewSizeX, uint32 NewSizeY, EWindowMode NewWindowMode, EPixelFormat PreferredPixelFormat){}
        void Draw( bool bShouldPresent = true );
    };
    class ViewportFrame
    {
    public:
        virtual Viewport* GetViewport() = 0;
        virtual void ResizeFrame(uint32 NewSizeX,uint32 NewSizeY,EWindowMode NewWindowMode) = 0;
    };
    class SceneViewport:public ViewportFrame, public Viewport
    {
    public:
        ViewportWidget*mViewportWidget;
        SceneViewport(ViewportClient*inViewportClient,ViewportWidget*inViewportWidget);
        /** FViewportFrame interface */
        virtual Viewport* GetViewport() override { return this; }
        virtual void ResizeFrame(uint32 NewSizeX,uint32 NewSizeY,EWindowMode NewWindowMode) override;
        virtual void ResizeViewport( uint32 NewSizeX,uint32 NewSizeY,EWindowMode NewWindowMode );
        virtual void UpdateViewportRHI(bool bDestroyed, uint32 NewSizeX, uint32 NewSizeY, EWindowMode NewWindowMode, EPixelFormat PreferredPixelFormat) override;
        //virtual ViewportFrame* GetViewportFrame() override { return this; }
    };
}
